﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WXYW.BLL;

namespace WXYW
{
    public partial class SearchProvider : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindUsers();
            }
        }

        protected void searchLinkButton_Click(object sender, EventArgs e)
        {
            BindUsers();
        }

        private void BindUsers()
        {
            ProviderService service = new ProviderService();
            ProviderGridView.DataSource = service.GetProviderByKeyword(keyWordTextBox.Text);
            ProviderGridView.DataBind();
        }

        protected void resetLinkButton_Click(object sender, EventArgs e)
        {
            keyWordTextBox.Text = "";
            BindUsers();
        }

        protected void ProviderGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            if (e.NewPageIndex >= 0 && e.NewPageIndex < ProviderGridView.PageCount)
            {
                ProviderGridView.PageIndex = e.NewPageIndex;
            }
            
            BindUsers();
        }
    }
}
